//
//  ContextMessageTable.m
//  OperationPro
//
//  Created by yaxue wang on 16/11/10.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "ContextMessageTable.h"
#import "ContextMessageCell.h"
#import "ContextMessageModel.h"
@implementation ContextMessageTable

- (void)initView{
    [super initView];
    [self setShowNoDataNotice:@"暂无内容"];
    self.backgroundColor =BackColor;
    self.separatorStyle=UITableViewCellSeparatorStyleNone;
    self.showsVerticalScrollIndicator =NO;
    [self registerCell:[ContextMessageCell class] withModel:[ContextMessageModel class]];
    [self setDataWithUrl:@"message_showReplyNotify" andParam:nil];
    [self setTableActionType:CTableActionType_Both];
    [self loadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.mainData.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  130;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellID = [NSString stringWithFormat:@"Cell_%@", NSStringFromClass([ContextMessageModel class])];
    ContextMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ContextMessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;

    ContextMessageModel *model = [self.mainData objectAtIndex:indexPath.row];
    [cell setModel:model];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    ContextMessageModel *model = [self.mainData objectAtIndex:indexPath.row];
    NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
    if(model.C_content==nil||[model.C_content isEqualToString:@""])
    {
        
    }else
    {
    [dic setObject:model.C_content forKey:@"warningUuid"];
    [CClass HttpRequestTask:YES withUrl:@"warninglist_getOrderInfo" withData:@{@"warningUuid":model.C_content} notifyError:YES onSuccess:^(BaseModel *model) {
        [dic setObject:[model.B_data objectForKey:@"state"] forKey:@"state"];
        if (self.CCellSelect) {
            self.CCellSelect(dic);
        }
        
        
    } onError:^(BaseModel *model) {
        
    }];
    }

}



@end
